<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图书管理系统</title>
    <!-- 引入Font Awesome图标库 -->
    <link href="icon/font-awesome.min.css" rel="stylesheet">
    <script src="js/Chart.js"></script>

    <!-- 引入外部css文件 -->
    <link rel="stylesheet" href="css/backend.css">

    <!-- 引入外部Js文件 -->
    <script src="js/jquery.3.7.1min.js" defer></script>
    <script src="js/backend.js" defer></script>


</head>

<body>
    <div class="container">
        <!-- 头部 -->
        <div class="header">
            <div class="left">
                <img src="https://picsum.photos/40/40?random=logo" alt="系统logo">
                <h3>图书管理系统</h3>
            </div>
            <div class="right">
                <ul>
                    <li><a href="">管理员</a></li>
                    <li><a href="#" id="logoutBtn"><i class="fa fa-sign-out mr-2"></i>退出登录</a></li>
                </ul>
            </div>
        </div>

        <!-- 侧边栏 -->
        <div class="sidebar">
            <ul>
                <li class="active">
                    <span><i class="fa fa-book mr-2"></i>主菜单</span>
                    <ul>
                        <li><a href="#" data-target="book-management" class="active"><i
                                    class="fa fa-book mr-2"></i>书籍管理</a></li>
                        <li><a href="#" data-target="user-management"><i class="fa fa-users mr-2"></i>用户管理</a></li>
                        <!-- <li><a href="#" data-target="category-management"><i class="fa fa-th-list mr-2"></i>书籍分类</a></li> -->
                        <li><a href="#" data-target="author-management"><i class="fa fa-pencil mr-2"></i>作家管理</a></li>
                    </ul>
                </li>
                <li>
                    <span><i class="fa fa-cogs mr-2"></i>运营管理</span>
                    <ul>
                        <li><a href="#" data-target="recommend1-management"><i class="fa fa-star mr-2"></i>推荐位管理1</a>
                        </li>
                        <li><a href="#" data-target="recommend2-management"><i
                                    class="fa fa-calendar mr-2"></i>推荐位管理2</a></li>
                        <li><a href="#" data-target="recommend3-management"><i
                                    class="fa fa-bar-chart mr-2"></i>推荐位管理3</a></li>
                    </ul>
                </li>
            </ul>
        </div>

        <!-- 主内容区 - 各功能模块封装为独立div -->
        <div class="main-content">
            <!-- 书籍管理页面 -->
            <div class="content-page active" id="book-management">
                <div class="content-header">
                    <h2>书籍管理</h2>
                    <div class="breadcrumb">
                        <a href="#">首页</a>
                        <span>/</span>
                        <a href="#">主菜单</a>
                        <span>/</span>
                        <span>书籍管理</span>
                    </div>
                </div>

                <!-- 数据卡片 -->
                <div class="cards">
                    <div class="card">
                        <div class="card-header">
                            <h3>总书籍数</h3>
                            <div class="icon"><i class="fa fa-book"></i></div>
                        </div>
                        <div class="card-body">
                            <div class="value">1,286</div>
                            <div class="change">
                                <i class="fa fa-arrow-up"></i> 12.5%
                            </div>
                        </div>
                    </div>

                    <div class="card">
                        <div class="card-header">
                            <h3>本月新增</h3>
                            <div class="icon"><i class="fa fa-plus-circle"></i></div>
                        </div>
                        <div class="card-body">
                            <div class="value">89</div>
                            <div class="change">
                                <i class="fa fa-arrow-up"></i> 8.2%
                            </div>
                        </div>
                    </div>

                    <div class="card">
                        <div class="card-header">
                            <h3>活跃用户</h3>
                            <div class="icon"><i class="fa fa-users"></i></div>
                        </div>
                        <div class="card-body">
                            <div class="value">3,642</div>
                            <div class="change">
                                <i class="fa fa-arrow-up"></i> 15.3%
                            </div>
                        </div>
                    </div>

                    <div class="card">
                        <div class="card-header">
                            <h3>借阅次数</h3>
                            <div class="icon"><i class="fa fa-exchange"></i></div>
                        </div>
                        <div class="card-body">
                            <div class="value">8,254</div>
                            <div class="change down">
                                <i class="fa fa-arrow-down"></i> 3.1%
                            </div>
                        </div>
                    </div>
                </div>

                <!-- 图表区域 -->
                <div class="charts">
                    <div class="chart-card">
                        <h3>书籍分类分布</h3>
                        <div class="chart-container">
                            <canvas id="categoryChart"></canvas>
                        </div>
                    </div>
                </div>

                <!-- 表格区域 -->
                <div class="table-card">
                    <div class="table-header">
                        <h3>书籍列表</h3>
                        <div class="search">
                            <i class="fa fa-search"></i>
                            <input type="text" placeholder="搜索书籍...">
                        </div>
                    </div>

                    <div class="table-responsive">
                        <table class="data-table">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <!-- <th>封面</th> -->
                                    <th>书名</th>
                                    <th>作者</th>
                                    <th>分类</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody class="book-list" data-type="book">
                                <tr data-id="001">
                                    <td>001</td>
                                    <!-- <td><img src="https://picsum.photos/40/60?random=1" alt="书籍封面" class="book-cover"> -->
                                    </td>
                                    <td>Python编程从入门到实践</td>
                                    <td>Eric Matthes</td>
                                    <td>计算机</td>
                                    <td><span class="status active">正常</span></td>
                                    <td>
                                        <div class="actions">
                                            <button class="action-btn" data-action="view" data-id="001"><i
                                                    class="fa fa-eye"></i></button>
                                            <button class="action-btn" data-action="edit" data-id="001"><i
                                                    class="fa fa-edit"></i></button>
                                            <button class="action-btn" data-action="delete" data-id="001"
                                                data-type="book"><i class="fa fa-trash"></i></button>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                    <div class="pagination">
                        <ul>
                            <li><a href="#">上一页</a></li>
                            <li><a href="#" class="active">1</a></li>
                            <li><a href="#">2</a></li>
                            <li><a href="#">3</a></li>
                            <li><a href="#">4</a></li>
                            <li><a href="#">5</a></li>
                            <li><a href="#">下一页</a></li>
                        </ul>
                    </div>
                </div>
            </div>

            <!-- 用户管理页面 -->
            <div class="content-page" id="user-management">
                <div class="content-header">
                    <h2>用户管理</h2>
                    <div class="breadcrumb">
                        <a href="#">首页</a>
                        <span>/</span>
                        <a href="#">主菜单</a>
                        <span>/</span>
                        <span>用户管理</span>
                    </div>
                </div>

                <div class="table-card">
                    <div class="table-header">
                        <h3>用户列表</h3>
                        <div class="search">
                            <i class="fa fa-search"></i>
                            <input type="text" placeholder="搜索用户...">
                        </div>
                    </div>

                    <div class="table-responsive">
                        <table class="data-table">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <!-- <th>头像</th> -->
                                    <th>用户名</th>
                                    <th>密码</th>
                                    <th>注册时间</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody class="user-list">
                                <tr data-id="U001">
                                    <td>U001</td>
                                    <!-- <td><img src="https://picsum.photos/40/40?random=user1" alt="用户头像"
                                            class="user-avatar"></td> -->
                                    <td>张三</td>
                                    <td>138****5678</td>
                                    <td>2024-01-15</td>
                                    <td><span class="status active">活跃</span></td>
                                    <td>
                                        <div class="actions">
                                            <button class="action-btn" data-action="view" data-id="U001"><i
                                                    class="fa fa-eye"></i></button>
                                            <button class="action-btn" data-action="edit" data-id="U001"><i
                                                    class="fa fa-edit"></i></button>
                                            <button class="action-btn" data-action="delete" data-id="U001"
                                                data-type="user"><i class="fa fa-trash"></i></button>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>

                    <div class="pagination">
                        <ul>
                            <li><a href="#">上一页</a></li>
                            <li><a href="#" class="active">1</a></li>
                            <li><a href="#">2</a></li>
                            <li><a href="#">3</a></li>
                            <li><a href="#">下一页</a></li>
                        </ul>
                    </div>
                </div>
            </div>


            <!-- 用户编辑模态框 -->
            <div class="modal" id="editUserModal">
                <div class="modal-content">
                    <div class="modal-header">
                        <h3>编辑用户信息</h3>
                        <span class="close" id="closeEditUserModal">&times;</span>
                    </div>
                    <div class="modal-body">
                        <form id="userEditForm">
                            <input type="hidden" id="editUserId">
                            <div class="form-group">
                                <label for="editUserName">用户名</label>
                                <input type="text" id="editUserName" name="userName" required>
                            </div>
                            <div class="form-group">
                                <label for="editUserPassword">密码</label>
                                <input type="text" id="editUserPassword" name="userPassword" required>
                            </div>
                            <div class="form-group">
                                <label for="editUserStatus">状态</label>
                                <select id="editUserStatus" name="userStatus" required>
                                    <option value="active">正常</option>
                                    <option value="inactive">禁用</option>
                                </select>
                            </div>
                            <!-- <div class="form-group">
                                <label>用户头像</label>
                                <div class="form-file">
                                    <label for="editUserAvatar" class="form-file-label">
                                        <i class="fa fa-image mr-2"></i>选择图片
                                    </label>
                                    <input type="file" id="editUserAvatar" name="userAvatar" accept="image/*">
                                </div>
                                <img src="" id="editUserAvatarPreview" class="form-file-preview" alt="头像预览">
                            </div> -->
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="cancel" id="cancelEditUser">取消</button>
                        <button type="button" class="save" id="saveEditUser">保存修改</button>
                    </div>
                </div>
            </div>


            <!-- 书籍分类页面 -->
            <div class="content-page" id="category-management">
                <div class="content-header">
                    <h2>书籍分类管理</h2>
                    <div class="breadcrumb">
                        <a href="#">首页</a>
                        <span>/</span>
                        <a href="#">主菜单</a>
                        <span>/</span>
                        <span>书籍分类</span>
                    </div>
                </div>

                <div class="cards">
                    <div class="card">
                        <div class="card-header">
                            <h3>总分类数</h3>
                            <div class="icon"><i class="fa fa-th-list"></i></div>
                        </div>
                        <div class="card-body">
                            <div class="value">18</div>
                            <div class="change">
                                <i class="fa fa-arrow-up"></i> 2个新增
                            </div>
                        </div>
                    </div>
                </div>

                <div class="table-card">
                    <div class="table-header">
                        <h3>分类列表</h3>
                        <button id="addCategoryBtn" class="add-btn"><i class="fa fa-plus mr-2"></i>添加分类</button>
                    </div>

                    <div class="table-responsive">
                        <table class="data-table">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>分类名称</th>
                                    <th>书籍数量</th>
                                    <th>创建时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <!-- <tr data-id="C001">
                                    <td>C001</td>
                                    <td>计算机</td>
                                    <td>256</td>
                                    <td>2023-10-01</td>
                                    <td>
                                        <div class="actions">
                                            <button class="action-btn" data-action="edit" data-id="C001"><i
                                                    class="fa fa-edit"></i></button>
                                            <button class="action-btn" data-action="delete" data-id="C001"
                                                data-type="category"><i class="fa fa-trash"></i></button>
                                        </div>
                                    </td>
                                </tr> -->
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            <!-- 作家管理页面 - 已修改以支持编辑功能 -->
            <div class="content-page" id="author-management">
                <div class="content-header">
                    <h2>作家管理</h2>
                    <div class="breadcrumb">
                        <a href="#">首页</a>
                        <span>/</span>
                        <a href="#">主菜单</a>
                        <span>/</span>
                        <span>作家管理</span>
                    </div>
                </div>

                <div class="table-card">
                    <div class="table-header">
                        <h3>作家列表</h3>
                        <div class="search">
                            <i class="fa fa-search"></i>
                            <input type="text" placeholder="搜索作家...">
                        </div>
                    </div>

                    <div class="table-responsive">
                        <table class="data-table">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>作家姓名</th>
                                    <th>地区</th>
                                    <th>作品数量</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody class="author-list">
                                <!-- <tr data-id="A001">
                                    <td>A001</td>
                                    <td>刘慈欣</td>
                                    <td>四川</td>
                                    <td>12</td>
                                    <td>
                                        <div class="actions">
                                            <button class="action-btn" data-action="view" data-id="A001"><i
                                                    class="fa fa-eye"></i></button>
                                            <button class="action-btn" data-action="edit" data-id="A001"><i
                                                    class="fa fa-edit"></i></button>
                                            <button class="action-btn" data-action="delete" data-id="A001"
                                                data-type="author"><i class="fa fa-trash"></i></button>
                                        </div>
                                    </td>
                                </tr> -->
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

            <!-- 作家编辑模态框 -->
            <div class="modal" id="editAuthorModal">
                <div class="modal-content">
                    <div class="modal-header">
                        <h3>编辑作家信息</h3>
                        <span class="close" id="closeEditAuthorModal">&times;</span>
                    </div>
                    <div class="modal-body">
                        <form id="authorEditForm">
                            <input type="hidden" id="editAuthorId">
                            <div class="form-group">
                                <label for="editAuthorName">作家姓名</label>
                                <input type="text" id="editAuthorName" name="authorName" required>
                            </div>
                            <div class="form-group">
                                <label for="editAuthorNationality">地区</label>
                                <input type="text" id="editAuthorNationality" name="authorNationality" required>
                            </div>
                            <!-- <div class="form-group">
                                <label for="editAuthorIntroduction">简介</label>
                                <textarea id="editAuthorIntroduction" name="authorIntroduction" rows="4"></textarea>
                            </div> -->
                            <div class="form-group">
                                <label for="editAuthorWorksCount">作品数量</label>
                                <input type="number" id="editAuthorWorksCount" name="authorWorksCount" min="0" required>
                            </div>
                            <!-- <div class="form-group">
                                <label>作家头像</label>
                                <div class="form-file">
                                    <label for="editAuthorAvatar" class="form-file-label">
                                        <i class="fa fa-image mr-2"></i>选择图片
                                    </label>
                                    <input type="file" id="editAuthorAvatar" name="authorAvatar" accept="image/*">
                                </div>
                                <img src="" id="editAuthorAvatarPreview" class="form-file-preview" alt="头像预览">
                            </div> -->
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="cancel" id="cancelEditAuthor">取消</button>
                        <button type="button" class="save" id="saveEditAuthor">保存修改</button>
                    </div>
                </div>
            </div>

            <!-- 推荐位管理1页面 -->
            <div class="content-page" id="recommend1-management">
                <div class="content-header">
                    <h2>推荐位管理1</h2>
                    <div class="breadcrumb">
                        <a href="#">首页</a>
                        <span>/</span>
                        <a href="#">运营管理</a>
                        <span>/</span>
                        <span>推荐位管理1</span>
                    </div>
                </div>

                <div class="cards">
                    <div class="card">
                        <div class="card-header">
                            <h3>推荐位统计</h3>
                            <div class="icon"><i class="fa fa-star"></i></div>
                        </div>
                        <div class="card-body">
                            <div class="value">24</div>
                            <div class="change">
                                <i class="fa fa-arrow-up"></i> 3个新增
                            </div>
                        </div>
                    </div>
                </div>

                <p>推荐位管理1页面内容将在这里显示</p>
            </div>

            <!-- 推荐位管理2页面 -->
            <div class="content-page" id="recommend2-management">
                <div class="content-header">
                    <h2>推荐位管理2</h2>
                    <div class="breadcrumb">
                        <a href="#">首页</a>
                        <span>/</span>
                        <a href="#">运营管理</a>
                        <span>/</span>
                        <span>推荐位管理2</span>
                    </div>
                </div>

                <p>推荐位管理2页面内容将在这里显示</p>
            </div>

            <!-- 推荐位管理3页面 -->
            <div class="content-page" id="recommend3-management">
                <div class="content-header">
                    <h2>推荐位管理3</h2>
                    <div class="breadcrumb">
                        <a href="#">首页</a>
                        <span>/</span>
                        <a href="#">运营管理</a>
                        <span>/</span>
                        <span>推荐位管理3</span>
                    </div>
                </div>

                <p>推荐位管理3页面内容将在这里显示</p>
            </div>
        </div>
    </div>

    <!-- 编辑书籍模态窗 -->
    <div class="modal" id="editBookModal">
        <div class="modal-content">
            <div class="modal-header">
                <h3>编辑书籍信息</h3>
                <span class="close" id="closeEditModal">&times;</span>
            </div>
            <div class="modal-body">
                <form id="bookEditForm">
                    <input type="hidden" id="editBookId">
                    <div class="form-group">
                        <label for="editBookName">书名</label>
                        <input type="text" id="editBookName" name="bookName" required>
                    </div>
                    <div class="form-group">
                        <label for="editBookAuthor">作者</label>
                        <input type="text" id="editBookAuthor" name="bookAuthor" required>
                    </div>
                    <div class="form-group">
                        <label for="editBookCategory">分类</label>
                        <select id="editBookCategory" name="bookCategory" required>
                            <option value="">请选择分类</option>
                            <option value="计算机">计算机</option>
                            <option value="文学">文学</option>
                            <option value="历史">历史</option>
                            <option value="科幻">科幻</option>
                            <option value="心理学">心理学</option>
                            <option value="其他">其他</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="editBookStatus">状态</label>
                        <select id="editBookStatus" name="bookStatus" required>
                            <option value="active">正常</option>
                            <option value="inactive">已下架</option>
                        </select>
                    </div>
                    <!-- <div class="form-group">
                        <label>封面图片</label>
                        <div class="form-file">
                            <label for="editBookCover" class="form-file-label">
                                <i class="fa fa-image mr-2"></i>选择图片
                            </label>
                            <input type="file" id="editBookCover" name="bookCover" accept="image/*">
                        </div>
                        <img src="" id="editBookCoverPreview" class="form-file-preview" alt="封面预览">
                    </div> -->
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="cancel" id="cancelEditBook">取消</button>
                <button type="button" class="save" id="saveEditBook">保存修改</button>
            </div>
        </div>
    </div>

    <!-- 删除确认弹窗 -->
    <div class="modal delete-modal" id="deleteConfirmModal">
        <div class="modal-content">
            <div class="modal-header">
                <h3>删除确认</h3>
                <span class="close" id="closeDeleteModal">&times;</span>
            </div>
            <div class="modal-body">
                <i class="fa fa-exclamation-triangle"></i>
                <p>您确定要删除 <strong id="deleteItemName"></strong> 吗？</p>
                <p>此操作不可恢复，请谨慎操作！</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="cancel" id="cancelDelete">取消</button>
                <button type="button" class="save delete-btn" id="confirmDelete">确认删除</button>
            </div>
        </div>
    </div>

    <!-- 操作提示元素 -->
    <div class="toast" id="toast">操作成功</div>
</body>

</html>